num_votes = {}
with open('input.txt', "r") as f:
    for i in f.readlines():
        candidate, votes = i.split()
        num_votes[candidate] = num_votes.get(candidate, 0) + int(votes)

for candidate, votes in sorted(num_votes.items()):
    print(candidate, votes)